<ControlTemplate xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:s="clr-namespace:SmartPaginator.Extensions">
    <ControlTemplate.Resources>
        <BooleanToVisibilityConverter x:Key="visibilityConverter" />
    </ControlTemplate.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0"
              Height="{Binding Path=HeaderHeight, RelativeSource={RelativeSource Mode=TemplatedParent}}"
              Margin="{Binding Path=HeaderMargin, RelativeSource={RelativeSource Mode=TemplatedParent}}">
            <ContentControl VerticalAlignment="Bottom"
                            Content="{Binding Path=PaginationInfo, RelativeSource={RelativeSource Mode=TemplatedParent}}"
                            ContentTemplate="{Binding Path=HeaderTemplate, RelativeSource={RelativeSource Mode=TemplatedParent}}"
                            Visibility="{Binding Path=ShowHeader, RelativeSource={RelativeSource Mode=TemplatedParent},
                                                 Converter={StaticResource visibilityConverter}}" />
        </Grid>
        <ContentControl Grid.Row="1"
                        Content="{Binding Path=ColumnGrid, RelativeSource={RelativeSource Mode=TemplatedParent}}"
                        Margin="{Binding Path=ContentMargin, RelativeSource={RelativeSource Mode=TemplatedParent}}" />
        <Grid Grid.Row="2"
              Height="{Binding Path=FooterHeight, RelativeSource={RelativeSource Mode=TemplatedParent}}"
              Margin="{Binding Path=FooterMargin, RelativeSource={RelativeSource Mode=TemplatedParent}}">
            <ContentControl VerticalAlignment="Top"
                            Content="{Binding Path=PaginationInfo, RelativeSource={RelativeSource Mode=TemplatedParent}}"
                            ContentTemplate="{Binding Path=FooterTemplate, RelativeSource={RelativeSource Mode=TemplatedParent}}"
                            Visibility="{Binding Path=ShowFooter, RelativeSource={RelativeSource Mode=TemplatedParent},
                                                 Converter={StaticResource visibilityConverter}}"/>
        </Grid>
    </Grid>
</ControlTemplate>